//https://blog.csdn.net/zl1zl2zl3/article/details/81357146
import { PureComponent } from 'react';
import {
    Row,
    Col,
    Form,
    Input,
    Button,
    Modal,
} from 'antd';

const FormItem = Form.Item;


//查看表单
@Form.create()
class ViewForm extends PureComponent {
    static defaultProps = {
        handleViewModalVisible: () => {},
    values: {},
};

constructor(props) {
    super(props);

    this.state = {
        formVals: {
            id: props.values.id,
            tablename: props.values.tablename,
            tableid: props.values.tableid,
            columnname: props.values.columnname,
            columncode: props.values.columncode,
            columntype: props.values.columntype,
            columnsequence: props.values.columnsequence,
            columnlength: props.values.columnlength,
            display: props.values.display,
            memo: props.values.memo,
        },
    };


}



renderContent = (formVals) => {
    const { form } = this.props;

    return (
        <Form  layout="vertical" hideRequiredMark>



                <Row gutter={{ md: 8, lg: 24, xl: 48 }}>



                    <Col  md={12} sm={24}>
	                    <FormItem  label="名称">
	                        {form.getFieldDecorator('tablename', {
	                        rules: [{ required: true, message: '请输入至少五个字符的名称！', min: 5 }],
	                        initialValue: formVals.tablename,
	                        })(<Input  readOnly placeholder="请输入" />)}
	                    </FormItem>
                    </Col>




                    <Col  md={12} sm={24}>
	                    <FormItem  label="列名称">
	                        {form.getFieldDecorator('columnname', {
	                        rules: [{ required: true, message: '请输入至少五个字符的列名称！', min: 5 }],
	                        initialValue: formVals.columnname,
	                        })(<Input  readOnly placeholder="请输入" />)}
	                    </FormItem>
                    </Col>
                </Row>

                <Row gutter={{ md: 8, lg: 24, xl: 48 }}>

                    <Col  md={12} sm={24}>
	                    <FormItem  label="列编码">
	                        {form.getFieldDecorator('columncode', {
	                        rules: [{ required: true, message: '请输入至少五个字符的列编码！', min: 5 }],
	                        initialValue: formVals.columncode,
	                        })(<Input  readOnly placeholder="请输入" />)}
	                    </FormItem>
                    </Col>




                    <Col  md={12} sm={24}>
	                    <FormItem  label="列类型">
	                        {form.getFieldDecorator('columntype', {
	                        rules: [{ required: true, message: '请输入至少五个字符的列类型！', min: 5 }],
	                        initialValue: formVals.columntype,
	                        })(<Input  readOnly placeholder="请输入" />)}
	                    </FormItem>
                    </Col>



                </Row>

                <Row gutter={{ md: 8, lg: 24, xl: 48 }}>


                    <Col  md={12} sm={24}>
	                    <FormItem  label="列顺序">
	                        {form.getFieldDecorator('columnsequence', {
	                        rules: [{ required: true, message: '请输入至少五个字符的列顺序！', min: 5 }],
	                        initialValue: formVals.columnsequence,
	                        })(<Input  readOnly placeholder="请输入" />)}
	                    </FormItem>
                    </Col>



                    <Col  md={12} sm={24}>
	                    <FormItem  label="列长度">
	                        {form.getFieldDecorator('columnlength', {
	                        rules: [{ required: true, message: '请输入至少五个字符的列长度！', min: 5 }],
	                        initialValue: formVals.columnlength,
	                        })(<Input  readOnly placeholder="请输入" />)}
	                    </FormItem>
                    </Col>


                </Row>

    </Form>
);

};



render() {
    const { viewModalVisible, handleViewModalVisible, values } = this.props;
    const { formVals } = this.state;

    return (
        <Modal
    width={800}
    bodyStyle={{ padding: '32px 40px 48px' }}
    destroyOnClose
    title="查看"
    visible={viewModalVisible}
    onCancel={() => handleViewModalVisible(false, values)}
    footer={<Button key="back" onClick = { () => handleViewModalVisible(false, values) }>取消</Button>}
>

    {this.renderContent(values)}
</Modal>
);
}

}

export default ViewForm;
